﻿/*-----------------------------------------------------------------------
 * <copyright file="DataProvider.cs" company="O-RID">
 *     Copyright (c)2010 O-RID Co.,Ltd.
 * </copyright>
 * <author>Zhang Jun</author>
 * <summary>
 *          所有与OP信息操作相关的所有服务
 *          WCFOPCorrelation.svc服务实现的具体方法
 *          Get（Set）+服务方法名
 *          作成日： 07/07/2010
 *          
 *          06/17/2011~06/20/2011 增加
 *          服务增加 案件名，线路 条件
 *          OP别日别查询	
 *          OP别期间别查询	
 *          
 * </summary>
 *-----------------------------------------------------------------------
 */
namespace Orid.Management.Statistics.Service.OPUnitService.OPCorrelation
{
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using Orid.Management.Statistics.Service.OPUnitService.OPCorrelation.ServiceModel;

    /// <summary>
    /// DataProvider
    /// 具体方法
    /// </summary>
    public class DataProvider
    {
        #region  OP别 日别 查询
        /// <summary>
        /// 显示 所有 符合查询条件的OP信息
        /// WCFOPEntrySpeedQuery
        /// OPEntrySpeedQueryControl.xaml
        /// 06/02/2010 修改 GetSelectOPEntrySpeedQueryInfor为存储过程 所以参数形式变更
        /// </summary>
        /// <param name="whereParametersList"> whereParametersList 形成的where条件</param>
        /// <returns>返回 OPDurationEntrySpeedQueryInforData 的 LIST 形式</returns>
        /// <value>
        ///     06/17/2011 增加 案件名，线路 条件
        ///     07/06/2011 增加 ImageType名片属性
        /// </value>
        public static List<OPEntrySpeedQueryInforDataList> 
                      GetSelectOPEntrySpeedQueryInfor(WhereParameters  whereParameter)
        {
            #region  summary
            // <summary>
            //          OP别 日别 查询
            //                  05/25/2010 修改 GetSelectOPEntrySpeedQueryInfor 中SQL
            //                  06/02/2010 修改 GetSelectOPEntrySpeedQueryInfor为存储过程 EntrySpeedBaseQueryDays
            //                  06/22/2010 修改 存储过程EntrySpeedBaseQueryDays 增加精度Accuracy
            //                  06/23/2010 修改 Accuracy为 ***.**%
            //                             添加 正确子画像数
            //                  06/24/2010 删除 GetTagInfor()方法
            //                  06/25/2010 删除 GetSelectSVOPInfor()方法
            // </summary>
            #endregion summary

            List<OPEntrySpeedQueryInforDataList> oPESQInforList = new List<OPEntrySpeedQueryInforDataList>();
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StatisticsToolsDB"].ConnectionString))
            {
                conn.Open();

                #region "SqlCommand"
                using (SqlCommand cmd = new SqlCommand("EntrySpeedBaseQueryDays", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@starDate", whereParameter.WhereentryDateFrom));
                    cmd.Parameters.Add(new SqlParameter("@FinishDate", whereParameter.WhereentryDateTo));
                    cmd.Parameters.Add(new SqlParameter("@ScriptType", SqlDbType.NVarChar));
                    cmd.Parameters["@ScriptType"].Value = whereParameter.WhereScriptType;
                    cmd.Parameters.Add(new SqlParameter("@WordType", SqlDbType.NVarChar));
                    cmd.Parameters["@WordType"].Value = whereParameter.WhereWordType;
                    cmd.Parameters.Add(new SqlParameter("@JobClass", SqlDbType.NVarChar));
                    cmd.Parameters["@JobClass"].Value = whereParameter.WhereJobClass;
                    cmd.Parameters.Add(new SqlParameter("@opID", SqlDbType.NVarChar));
                    cmd.Parameters["@opID"].Value = whereParameter.WhereLoginName;
                    cmd.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar));
                    cmd.Parameters["@unit"].Value = whereParameter.WhereUnit;

                    // 06/17/2011 增加 案件名，线路 条件
                    cmd.Parameters.Add(new SqlParameter("@MatterID", SqlDbType.NVarChar));
                    cmd.Parameters["@MatterID"].Value = whereParameter.WhereMatterName;
                    cmd.Parameters.Add(new SqlParameter("@Lines", SqlDbType.NVarChar));
                    cmd.Parameters["@Lines"].Value = whereParameter.WhereServer;


                    cmd.CommandTimeout = 5000; 

                    SqlDataReader reaccount = cmd.ExecuteReader();

                    while (reaccount.Read())
                    {
                        oPESQInforList.Add(new OPEntrySpeedQueryInforDataList()
                        {
                            EntryDate = Common.MyToFormat(reaccount, "EntryDate", Common.ClassType.DATETIME, "yyyy-MM-dd"),
                            LoginName = Common.MyIsDBNull(reaccount, "LoginName", true),
                            OpName = Common.MyIsDBNull(reaccount, "OpName"),
                            Unit = Common.MyIsDBNull(reaccount, "Unit"),
                            MatterID = Common.MyIsDBNull(reaccount, "MatterID"),
                            MatterName = Common.MyIsDBNull(reaccount, "MatterName"),
                            ScriptType = Common.MyIsDBNull(reaccount, "ScriptType"),
                            WordType = Common.MyIsDBNull(reaccount, "WordType"),
                            JobClass = Common.MyIsDBNull(reaccount, "jobClass"),
                            MaServer = Common.MyIsDBNull(reaccount, "Maserver"), //--06/03/2010--ADD
                            ChildDataCount = Common.MyToFormat(reaccount, "ChildDataCount", Common.ClassType.DOUBLE, "#,##0"),
                            WordCount = Common.MyToFormat(reaccount, "WordCount", Common.ClassType.DOUBLE , "#,##0"),
                            Duration = Common.MyToFormat(reaccount, "duration", Common.ClassType.DOUBLE , "#,##0.00"),
                            WordEntrySpeed = Common.MyIsDBNull(reaccount, "WordEntrySpeed"),
                            ChildDataEntrySpeed = Common.MyIsDBNull(reaccount, "ChildDataEntrySpeed"),

                            // -----05/25/2010---ADD--
                            ChildDataEntrySpeedAvg = Common.MyIsDBNull(reaccount, "ChildDataEntrySpeedAvg"),
                            ChildDataEntrySpeedUnitAvg = Common.MyIsDBNull(reaccount, "ChildDataEntrySpeedUnitAvg"),
                            WordEntrySpeedAvg = Common.MyIsDBNull(reaccount, "WordEntrySpeedAvg"),
                            WordEntrySpeedUnitAvg = Common.MyIsDBNull(reaccount, "WordEntrySpeedUnitAvg"),

                            // 2010/06-22  add by lidawei -- 06/23/2010 修改 Accuracy为 ***.**%　by zj
                            Accuracy = Common.MyToFormat(reaccount, "Accuracy", Common.ClassType.DOUBLE , "%"),

                            // 06/23/2010 -- 添加 正确子画像数 by zj
                            OKChildDataCount =Common.MyIsDBNull(reaccount,"OKChildDataCount"),
                            
                            // 07/06/2011 增加 ImageType名片属性
                            ImageType = Common.MyIsDBNull(reaccount, "ImageType")

                        });
                    }

                    reaccount.Close();
                    conn.Close();
                }

                return oPESQInforList;
            #endregion SqlCommand

            }
        }
        #endregion  OP别 日别 查询

        #region OP别 期间别 查询
        /// <summary>
        /// 显示 所有 符合查询条件的OP信息
        /// WCFOPDurationEntrySpeedQuery
        /// 06/22/2010  
        /// </summary>
        /// <param name="whereParametersList"> whereParametersList 形成的where条件</param>
        /// <returns>返回 OPDurationEntrySpeedQueryInforData 的 LIST 形式</returns>
        /// <value>
        /// 07/06/2011 增加 ImageType名片属性
        /// </value>
        public static List<OPDurationEntrySpeedQueryInforData>
                      GetSelectOPDurationEntrySpeedQueryInfor(List<WhereParameters> whereParametersList)
        {
            #region  <summary>
            // <summary>
            //          作成日：05/21/2010
            //          06/22/2010 修改 存储过程EntrySpeedBaseQueryOperators 增加精度Accuracy
            //          06/23/2010 修改 Accuracy为 ***.**%
            //                     添加 正确子画像数
            // </summary>
            #endregion </summary>

            List<OPDurationEntrySpeedQueryInforData> oPESQInforList = new List<OPDurationEntrySpeedQueryInforData>();
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StatisticsToolsDB"].ConnectionString))
            {
                conn.Open();

                #region "SqlCommand"
                using (SqlCommand cmd = new SqlCommand("EntrySpeedBaseQueryOperators", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@starDate", whereParametersList[0].WhereentryDateFrom));
                    cmd.Parameters.Add(new SqlParameter("@FinishDate", whereParametersList[0].WhereentryDateTo));
                    cmd.Parameters.Add(new SqlParameter("@ScriptType", SqlDbType.NVarChar));
                    cmd.Parameters["@ScriptType"].Value = whereParametersList[0].WhereScriptType;
                    cmd.Parameters.Add(new SqlParameter("@WordType", SqlDbType.NVarChar));
                    cmd.Parameters["@WordType"].Value = whereParametersList[0].WhereWordType;
                    cmd.Parameters.Add(new SqlParameter("@JobClass", SqlDbType.NVarChar));
                    cmd.Parameters["@JobClass"].Value = whereParametersList[0].WhereJobClass;
                    cmd.Parameters.Add(new SqlParameter("@opID", SqlDbType.NVarChar));
                    cmd.Parameters["@opID"].Value = whereParametersList[0].WhereLoginName;
                    cmd.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar));
                    cmd.Parameters["@unit"].Value = whereParametersList[0].WhereUnit;

                    // 06/20/2011 增加 案件名，线路 条件
                    cmd.Parameters.Add(new SqlParameter("@MatterID", SqlDbType.NVarChar));
                    cmd.Parameters["@MatterID"].Value = whereParametersList[0].WhereMatterName;
                    cmd.Parameters.Add(new SqlParameter("@Lines", SqlDbType.NVarChar));
                    cmd.Parameters["@Lines"].Value = whereParametersList[0].WhereServer;


                    cmd.CommandTimeout = 180; // 3分钟

                    SqlDataReader reaccount = cmd.ExecuteReader();

                    while (reaccount.Read())
                    {
                        oPESQInforList.Add(new OPDurationEntrySpeedQueryInforData()
                        {
                            LoginName = Common.MyIsDBNull(reaccount, "LoginName", true),
                            OpName = Common.MyIsDBNull(reaccount, "OpName"),
                            Unit = Common.MyIsDBNull(reaccount, "Unit"),
                            MatterID = Common.MyIsDBNull(reaccount, "MatterID"),
                            MatterName = Common.MyIsDBNull(reaccount, "MatterName"),
                            ScriptType = Common.MyIsDBNull(reaccount, "ScriptType"),
                            WordType = Common.MyIsDBNull(reaccount, "WordType"),
                            JobClass = Common.MyIsDBNull(reaccount, "jobClass"),
                            MaServer = Common.MyIsDBNull(reaccount, "Maserver"),
                            ChildDataCount = Common.MyToFormat(reaccount, "ChildDataCount", Common.ClassType.DOUBLE , "#,##0"),
                            WordCount = Common.MyToFormat(reaccount, "WordCount", Common.ClassType.DOUBLE , "#,##0"),
                            Duration = Common.MyToFormat(reaccount, "duration", Common.ClassType.DOUBLE , "#,##0.00"),
                            WordEntrySpeed = Common.MyIsDBNull(reaccount, "WordEntrySpeed"),
                            ChildDataEntrySpeed = Common.MyIsDBNull(reaccount, "ChildDataEntrySpeed"),

                            ChildDataEntrySpeedAvg = Common.MyIsDBNull(reaccount, "ChildDataEntrySpeedAvg"),
                            ChildDataEntrySpeedUnitAvg = Common.MyIsDBNull(reaccount, "ChildDataEntrySpeedUnitAvg"),
                            WordEntrySpeedAvg = Common.MyIsDBNull(reaccount, "WordEntrySpeedAvg"),
                            WordEntrySpeedUnitAvg = Common.MyIsDBNull(reaccount, "WordEntrySpeedUnitAvg"),

                            //// 2010/06-22  add by lidawei
                            Accuracy = Common.MyToFormat(reaccount, "Accuracy", Common.ClassType.DOUBLE , "%"),

                            //// 06/23/2010 -- 添加 正确子画像数 by zj
                            OKChildDataCount = Common.MyIsDBNull(reaccount, "OKChildDataCount"),

                            // 07/06/2011 增加 ImageType名片属性
                            ImageType = Common.MyIsDBNull(reaccount, "ImageType")
                        });
                    }

                    reaccount.Close();
                    conn.Close();
                }

                return oPESQInforList;

                #endregion SqlCommand
            }
        }
        #endregion OP别 期间别 查询

        #region OP 稼动率 查询
        // <summary>
        //          作成日：06/01/2010
        //                  06/01/2010 添加 OP稼动率查询（GetSelectOPWorkEfficiency）通过调用存储过程，来实现查询
        //                  06/02/2010 添加 GetSelectOPWorkEfficiency--格式化千位分割符 
        //                  修改 View_WorkEfficiencyBase改为StatisticsToolsDB.Dict（GetSelectStatsticClass）
        //                  06/28/2010 把查询稼动率类型的服务GetSelectStatsticClass移除
        // </summary>
        #region OP稼动率查询_Hour
        /// <summary>
        /// OP稼动率 查询_Hour
        /// 通过调用存储过程，来实现查询
        /// OPWorkEfficiencyQueryControl.xaml中的DataGrid
        /// </summary>
        /// <param name="whereParametersList">where 的参数列表</param>
        /// <returns>返回 WorkEfficiencyDataList 的LIST 形式</returns>
        public static List<WorkEfficiencyDataList> GetSelectOPWorkEfficiencyHour(List<WhereParametersForWorkEff> whereParametersList)
        {
            List<WorkEfficiencyDataList> oPWorkEfficiencyList = new List<WorkEfficiencyDataList>();
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StatisticsToolsDB"].ConnectionString))
            {
                conn.Open();

                ////[StatisticsToolsDB].dbo.WorkEfficiencyQueryHours

                #region "SqlCommand" 执行存储过程  WorkEfficiencyQueryHours
                using (SqlCommand cmd = new SqlCommand("WorkEfficiencyQueryHours", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@starDate", SqlDbType.DateTime));
                    cmd.Parameters["@starDate"].Value = whereParametersList[0].WhereentryDateFrom;

                    cmd.Parameters.Add(new SqlParameter("@FinishDate", SqlDbType.DateTime));
                    cmd.Parameters["@FinishDate"].Value = whereParametersList[0].WhereentryDateTo;

                    cmd.Parameters.Add(new SqlParameter("@opID", SqlDbType.NVarChar));
                    cmd.Parameters["@opID"].Value = whereParametersList[0].WhereLoginName;

                    cmd.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar));
                    cmd.Parameters["@unit"].Value = whereParametersList[0].WhereUnit;

                    cmd.CommandTimeout = 180;

                    SqlDataReader reaccount = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    while (reaccount.Read())
                    {
                        oPWorkEfficiencyList.Add(new WorkEfficiencyDataList()
                        {
                            EntryDate = Common.MyIsDBNull(reaccount, "EntryDate"),
                            LoginName = Common.MyIsDBNull(reaccount, "LoginName"),
                            OpName = Common.MyIsDBNull(reaccount, "OpName"),
                            Unit = Common.MyIsDBNull(reaccount, "Unit"),

                            ZeroOClock = Common.MyIsDBNull(reaccount, "0"),
                            OneOClock = Common.MyIsDBNull(reaccount, "1"),
                            TwoOClock = Common.MyIsDBNull(reaccount, "2"),
                            ThreeOClock = Common.MyIsDBNull(reaccount, "3"),
                            FourOClock = Common.MyIsDBNull(reaccount, "4"),
                            FiveOClock = Common.MyIsDBNull(reaccount, "5"),
                            SixOClock = Common.MyIsDBNull(reaccount, "6"),
                            SevenOClock = Common.MyIsDBNull(reaccount, "7"),
                            EightOClock = Common.MyIsDBNull(reaccount, "8"),
                            NineOClock = Common.MyIsDBNull(reaccount, "9"),
                            TenOClock = Common.MyIsDBNull(reaccount, "10"),
                            ElevenOClock = Common.MyIsDBNull(reaccount, "11"),
                            TwelveOClock = Common.MyIsDBNull(reaccount, "12"),
                            ThirteenOClock = Common.MyIsDBNull(reaccount, "13"),
                            FourteenOClock = Common.MyIsDBNull(reaccount, "14"),
                            FifteenOClock = Common.MyIsDBNull(reaccount, "15"),
                            SixteenOClock = Common.MyIsDBNull(reaccount, "16"),
                            SeventeenOClock = Common.MyIsDBNull(reaccount, "17"),
                            EighteenOClock = Common.MyIsDBNull(reaccount, "18"),
                            NineteenOClock = Common.MyIsDBNull(reaccount, "19"),
                            TwentyOClock = Common.MyIsDBNull(reaccount, "20"),
                            TwentyoneOClock = Common.MyIsDBNull(reaccount, "21"),
                            TwentytwoOClock = Common.MyIsDBNull(reaccount, "22"),
                            TwentythreeOClock = Common.MyIsDBNull(reaccount, "23"),
                        });
                    }

                    reaccount.Close();
                    conn.Close();
                }

                return oPWorkEfficiencyList;
                #endregion SqlCommand
            }
        }
        #endregion OP稼动率查询_Hour

        #region OP稼动率查询_Day
        /// <summary>
        /// OP稼动率_Day 查询
        /// 通过调用存储过程，来实现查询
        /// OPWorkEfficiencyQueryControl.xaml中的DataGrid
        /// </summary>
        /// <param name="WhereParametersForWorkEff">where 的参数列表</param>
        /// <returns>返回 WorkEfficiencyDataList 的LIST 形式</returns>
        public static List<WorkEfficiencyDataList> GetSelectOPWorkEfficiencyDay(List<WhereParametersForWorkEff> whereParametersList)
        {
            List<WorkEfficiencyDataList> oPWorkEfficiencyList = new List<WorkEfficiencyDataList>();
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StatisticsToolsDB"].ConnectionString))
            {
                conn.Open();

                #region "SqlCommand" 执行存储过程  WorkEfficiencyQueryHours
                using (SqlCommand cmd = new SqlCommand("WorkEfficiencyQueryDays", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@starDate", SqlDbType.DateTime));
                    cmd.Parameters["@starDate"].Value = whereParametersList[0].WhereentryDateFrom;

                    cmd.Parameters.Add(new SqlParameter("@FinishDate", SqlDbType.DateTime));
                    cmd.Parameters["@FinishDate"].Value = whereParametersList[0].WhereentryDateTo;

                    cmd.Parameters.Add(new SqlParameter("@opID", SqlDbType.NVarChar));
                    cmd.Parameters["@opID"].Value = whereParametersList[0].WhereLoginName;

                    cmd.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar));
                    cmd.Parameters["@unit"].Value = whereParametersList[0].WhereUnit;

                    cmd.CommandTimeout = 180;

                    SqlDataReader reaccount = cmd.ExecuteReader(CommandBehavior.CloseConnection);

                    while (reaccount.Read())
                    {
                        #region WorkEfficiencyQueryDays

                        oPWorkEfficiencyList.Add(new WorkEfficiencyDataList()
                        {
                            EntryDate = Common.MyIsDBNull(reaccount, "EntryDate"),
                            LoginName = Common.MyIsDBNull(reaccount, "LoginName", true),
                            OpName = Common.MyIsDBNull(reaccount, "OpName"),
                            Unit = Common.MyIsDBNull(reaccount, "Unit"),
                            EmpID = Common.MyIsDBNull(reaccount, "EmpID"),
                            Level = Common.MyIsDBNull(reaccount, "Level"),
                            SV = Common.MyIsDBNull(reaccount, "SV"),
                            Duration = Common.MyIsDBNull(reaccount, "Duration"),
                            ////06/02/2010 添加 GetSelectOPWorkEfficiency--格式化千位分割符 
                            PropagationTime = Common.MyToFormat(reaccount, "PropagationTime", Common.ClassType.DOUBLE, "#,##0.00"),

                            StatsticClass = Common.MyIsDBNull(reaccount, "StatsticClass"),

                            ////06/02/2010 添加 GetSelectOPWorkEfficiency--格式化千位分割符 
                            DutyDuration = Common.MyToFormat(reaccount, "DutyDuration", Common.ClassType.DOUBLE, "#,###"),

                            EntryRate = Common.MyIsDBNull(reaccount, "EntryRate"),
                        });

                        #endregion WorkEfficiencyQueryHours
                    }

                    reaccount.Close();
                    conn.Close();
                }

                return oPWorkEfficiencyList;
                #endregion SqlCommand
            }
        }
        #endregion OP稼动率查询_Day

        #endregion OP 稼动率 查询

        #region OP别 总成绩
        /// <summary>
        /// OP成绩 查询
        /// 通过调用存储过程，来实现查询
        /// OPEntryScoreDetailQueryControl.xaml中的DataGrid
        /// </summary>
        /// <param name="parameters">parameters 条件参数列表</param>
        /// <returns>返回 ScoreData 的 LIST 形式</returns>
        public static List<ScoreData> GetSelectEntryScore(WhereParameters parameters)
        {
            List<ScoreData> scoreList = new List<ScoreData>();
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StatisticsToolsDB"].ConnectionString))
            {
                conn.Open();

                #region "SqlCommand" 执行存储过程  EntryScoreQuery
                using (SqlCommand cmd = new SqlCommand("EntryScoreQuery", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@starDate", SqlDbType.DateTime));
                    cmd.Parameters["@starDate"].Value = parameters.WhereentryDateFrom;

                    cmd.Parameters.Add(new SqlParameter("@FinishDate", SqlDbType.DateTime));
                    cmd.Parameters["@FinishDate"].Value = parameters.WhereentryDateTo;

                    cmd.CommandTimeout = 180;
                    SqlDataReader reaccount = cmd.ExecuteReader();

                    while (reaccount.Read())
                    {
                        #region EntryScoreQuery

                        scoreList.Add(new ScoreData()
                        {
                            No = Common.MyIsDBNull(reaccount, "No"),
                            EmpID = Common.MyIsDBNull(reaccount, "EmpID"),
                            OpID = Common.MyIsDBNull(reaccount, "OpID"),
                            OpName = Common.MyIsDBNull(reaccount, "OpName"),
                            Unit = Common.MyIsDBNull(reaccount, "Unit"),
                            SV = Common.MyIsDBNull(reaccount, "SV"),
                            Complain = Common.MyIsDBNull(reaccount, "Complain"),
                            FinalPoint = Common.MyToFormat(reaccount, "FinalPoint", Common.ClassType.DOUBLE, "#,##0.00"),
                            Rank = Common.MyIsDBNull(reaccount, "Rank"),
                            CurrentLevel = Common.MyIsDBNull(reaccount, "CurrentLevel"),
                            LastLevel = Common.MyIsDBNull(reaccount, "LastLevel"),
                            LevelChange = Common.MyIsDBNull(reaccount, "LevelChange"),
                        });

                        #endregion EntryScoreQuery
                    }

                    reaccount.Close();
                    conn.Close();
                }

                return scoreList;
                #endregion SqlCommand
            }
        }
        #endregion OP别 总成绩

        #region  OP别 详细成绩
        /// <summary>
        /// OP详细成绩 查询
        /// 通过调用存储过程，来实现查询
        /// OPEntryScoreDetailQueryControl.xaml中的DataGrid
        /// </summary>
        /// <param name="parameters">parameters 条件参数列表</param>
        /// <returns>返回 ScoreDetailData 的 LIST 形式</returns>
        /// <value> 增加 案件名，线路查询条件 07/06/2011 Add</value>
        public static List<ScoreDetailData> GetSelectEntryScoreDetail(WhereParameters parameters)
        {
            List<ScoreDetailData> scoreDetailDataListList = new List<ScoreDetailData>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["StatisticsToolsDB"].ConnectionString))
            {
                conn.Open();

                string procedureName = "EntryScoreDetailQuery";

                #region "SqlCommand" 执行存储过程  EntryScoreDetailQuery

                using (SqlCommand cmd = new SqlCommand(procedureName, conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(new SqlParameter("@starDate", SqlDbType.DateTime));
                    cmd.Parameters["@starDate"].Value = parameters.WhereentryDateFrom;
                    cmd.Parameters.Add(new SqlParameter("@FinishDate", SqlDbType.DateTime));
                    cmd.Parameters["@FinishDate"].Value = parameters.WhereentryDateTo;
                    cmd.Parameters.Add(new SqlParameter("@ScriptType", SqlDbType.NVarChar));
                    cmd.Parameters["@ScriptType"].Value = parameters.WhereScriptType;
                    cmd.Parameters.Add(new SqlParameter("@WordType", SqlDbType.NVarChar));
                    cmd.Parameters["@WordType"].Value = parameters.WhereWordType;
                    cmd.Parameters.Add(new SqlParameter("@JobClass", SqlDbType.NVarChar));
                    cmd.Parameters["@JobClass"].Value = parameters.WhereJobClass;
                    cmd.Parameters.Add(new SqlParameter("@opID", SqlDbType.NVarChar));
                    cmd.Parameters["@opID"].Value = parameters.WhereLoginName;
                    cmd.Parameters.Add(new SqlParameter("@unit", SqlDbType.NVarChar));
                    cmd.Parameters["@unit"].Value = parameters.WhereUnit;
                    
                    // 07/06/2011 add 
                    cmd.Parameters.Add(new SqlParameter("@MatterID", SqlDbType.NVarChar));
                    cmd.Parameters["@MatterID"].Value = parameters.WhereMatterName;
                    cmd.Parameters.Add(new SqlParameter("@Lines", SqlDbType.NVarChar));
                    cmd.Parameters["@Lines"].Value = parameters.WhereServer;

                    cmd.CommandTimeout = 180;

                    SqlDataReader reaccount = cmd.ExecuteReader();

                    while (reaccount.Read())
                    {
                        #region ScoreDetailQuery

                        scoreDetailDataListList.Add(new ScoreDetailData()
                        {
                            /*EntryDate, OPID, OpName, Unit, EmpID, 
                             * Level, Sv, complain, state, MaServer, 
                             * MatterID, MatterName, ScriptType, WordType, jobClass, WordCount,
                             * duration, ChildDataCount, OKChildDataCount, 
                             * AvgEntrySpeed, OKRate, Point, AdditionPont, TotalPoint
                            */

                            EntryDate = Common.MyToFormat(reaccount, "EntryDate", Common.ClassType.DATETIME, "yyyy-MM-dd HH:mm:ss"),
                            LoginName = Common.MyIsDBNull(reaccount, "LoginName", true),
                            OpName = Common.MyIsDBNull(reaccount, "OpName"),
                            Unit = Common.MyIsDBNull(reaccount, "Unit"),
                            EmpID = Common.MyIsDBNull(reaccount, "EmpID"),
                            Level = Common.MyIsDBNull(reaccount, "Level"),
                            SV = Common.MyIsDBNull(reaccount, "SV"),
                            Complain = Common.MyIsDBNull(reaccount, "complain"),
                            State = Common.MyIsDBNull(reaccount, "state"),
                            MaServer = Common.MyIsDBNull(reaccount, "MaServer"),
                            MatterID = Common.MyIsDBNull(reaccount, "MatterID"),
                            MatterName = Common.MyIsDBNull(reaccount, "MatterName"),
                            ScriptType = Common.MyIsDBNull(reaccount, "ScriptType"),
                            WordType = Common.MyIsDBNull(reaccount, "WordType"),
                            JobClass = Common.MyIsDBNull(reaccount, "JobClass"),
                            WordCount = Common.MyToFormat(reaccount, "WordCount", Common.ClassType.DOUBLE, "#,##0"),
                            Duration = Common.MyToFormat(reaccount, "Duration", Common.ClassType.DOUBLE, "#,##0.00"),
                            ChildDataCount = Common.MyToFormat(reaccount, "ChildDataCount", Common.ClassType.DOUBLE, "#,###"),
                            OkChildDataCount = Common.MyToFormat(reaccount, "OKChildDataCount", Common.ClassType.DOUBLE, "#,##0"),
                            AvgEntrySpeed = Common.MyToFormat(reaccount, "AvgEntrySpeed", Common.ClassType.DOUBLE, "#,##0.00"),
                            OkRate = Common.MyToFormat(reaccount, "OKRate", Common.ClassType.DOUBLE, "%"),
                            Point = Common.MyToFormat(reaccount, "Point", Common.ClassType.DOUBLE, "#,##0.00"),
                            AdditionPont = Common.MyToFormat(reaccount, "AdditionPont", Common.ClassType.DOUBLE, "#,##0.00"),
                            TotalPoint = Common.MyToFormat(reaccount, "TotalPoint", Common.ClassType.DOUBLE, "#,##0.00")
                        });

                        #endregion EntryScoreDetailQuery
                    }

                    reaccount.Close();
                    conn.Close();
                }

                return scoreDetailDataListList;
                #endregion SqlCommand
            }
        }
        #endregion  OP别 详细成绩
    }
}
